
#!/bin/bash
# IP Function RegAddr
#Fuction:  1 byte
#0x3 : read 
#0x6: write

#RegAddr : 2 byte  #big-endian

#write:
#./set_palert IP 0x6 Regaddr value(2btye)
#read
#./set_palert IP 0x3 Regaddr Count (2 byte)
###################################

#get Palert IP addr

IP=192.168.255.5 

get_ip() {
echo "Get Palert IP addr"
./set_palert  $IP 03 00 AF 00 04

}

set_ip() {

echo "Set Palert IP addr, eg. 192.168.255.5"

# Set Palert IP addr, eg. 192.168.255.5
./set_palert  $IP 06 00 B3 00 C0		
./set_palert  $IP 06 00 B4 00 A8		
./set_palert  $IP 06 00 B5 00 FF		
./set_palert  $IP 06 00 B6 00 5		
#. write eeprom to save setting
./set_palert  $IP 06 00 70 00 04 


}

set_client_mode() {

#set 192.168.255.9
#. set server 0 aaa.bbb (192.168)
./set_palert  $IP 06 00 AF C0 A8   	
#. set server 0 ccc.ddd (255.9)
./set_palert  $IP 06 00 B0 FF 09	  	
#. set auto link server0 (bit 3)
# set Modbus TCP client	(bit 3+ bit 15)
./set_palert  $IP 06 00 75 80 08

#5. write eeprom
./set_palert  $IP 06 00 70 00 02

}

#set_client_mode
 #./set_palert  $IP 03 00 63 00 66

 if [ $? != 0 ]; then exit 1; fi
 get_ip
 if [ $? != 0 ]; then exit 1; fi

# 

